package org.nowcoder.leetcode.sort;

/**
 * Title  : 220. Contains Duplicate III
 * Source : https://leetcode.cn/problems/contains-duplicate-iii/
 * Author : XrazYang
 * Date   : 2023-09-20
 */
public class LeetCode_220 {
    public boolean containsNearbyAlmostDuplicate(int[] nums, int indexDiff, int valueDiff) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j <= i + indexDiff && j < nums.length; j++) {
                if (Math.abs(nums[i] - nums[j]) <= valueDiff) {
                    return true;
                }
            }
        }
        return false;
    }
}
